package com.cy.pj.goods.dao;

import com.cy.pj.goods.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface BrandDao {

    /*
    基于name值得不同，可能需要如下两种sql实现
    Select * from tb_goods;
    Select * from tb_goods where name like concat("%",#{name},"%");
     */
    List<Brand> findBrands(String name);

    @Delete("delete from tb_goods where id=#{id}")
    int deleteById(Integer id);
    /*将内存中得数据写入到数据库可以持久保存*/
    @Insert("insert into tb_goods(name,remark,createdTime) value(#{name},#{remark},now())")
    int insertBrand(Brand brand);

    @Select("select * from tb_goods where id=#{id}")
     Brand findById(Integer id);

    @Update("update tb_goods set name=#{name},remark=#{remark} where id=#{id}")
    int updateBrand(Brand brand);
}
